package com.example.dataimport.sqlprovider;

import java.util.HashMap;
import java.util.Map;

public class ExcelImportSqlProvider {




    public String insertARecordSqlB(String tableName, Map<String, String> params){
        StringBuilder resultSB = new StringBuilder("insert into ");
        resultSB.append(tableName);

        StringBuilder keySB = new StringBuilder("");
        StringBuilder valueSB = new StringBuilder("");


        for (String key:params.keySet()) {
            keySB.append(",").append(key);
            valueSB.append(",").append("'").append(params.get(key)).append("'");
        };

        resultSB.append("(").append(keySB.toString().substring(1)).append(")");
        resultSB.append(" values ").append("(").append(valueSB.toString().substring(1)).append(")");

        System.out.println(resultSB.toString());

        return resultSB.toString();
    }

    public String insertARecordSql(Map<String, Object> para){
        String tableName = para.get("tableName").toString();
        Map<String, String> params = (HashMap)para.get("params");
        return insertARecordSqlB(tableName, params);
    }
}
